<template>
  <div class="activity-container">
    <Header />
    
    <div class="activity-content">
      <!-- 页面标题区域 -->
      <div class="page-header">
        <h2 class="page-title">社团活动</h2>
        <p class="page-subtitle">记录我们的成长足迹，展示广播台的精彩瞬间</p>
      </div>
      
      <!-- 活动卡片容器 -->
      <div class="activities-wrapper">
        <!-- 全台大会 -->
        <div class="activity-card">
          <div class="activity-header">
            <div class="activity-badge">年度盛会</div>
            <h3 class="activity-title">全台大会</h3>
          </div>
          
          <div class="activity-intro">
            <p>全台大会是东软之声广播台一年一度的重要集会，旨在总结过往工作、规划未来发展方向，促进各部门成员之间的交流与合作。大会通常包含年度工作报告、优秀成员表彰、节目成果展示等环节，是广播台凝聚力量、共话发展的重要平台。</p>
          </div>
          
          <div class="activity-review">
            <h4 class="review-title">往届回顾</h4>
            <div class="carousel-wrapper">
              <div class="carousel">
                <div class="slides" :style="{ transform: `translateX(-${currentSlide.quanta * 100}%)` }">
                  <div class="slide" v-for="(item, index) in quantaBanners" :key="index">
                    <img :src="item.img" class="carousel-image" :alt="item.title">
                    <div class="carousel-caption">
                      <h3>{{ item.title }}</h3>
                      <p>{{ item.desc }}</p>
                    </div>
                  </div>
                </div>
                <button class="carousel-control prev" @click="prevSlide('quanta')">❮</button>
                <button class="carousel-control next" @click="nextSlide('quanta')">❯</button>
                <div class="carousel-indicators">
                  <span v-for="(item, index) in quantaBanners" 
                        :key="index" 
                        :class="{ active: currentSlide.quanta === index }"
                        @click="goToSlide('quanta', index)"></span>
                </div>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 配音秀大赛 -->
        <div class="activity-card">
          <div class="activity-header">
            <div class="activity-badge">特色赛事</div>
            <h3 class="activity-title">配音秀大赛</h3>
          </div>
          
          <div class="activity-intro">
            <p>配音秀大赛是广播台主办的特色校园文化活动，面向全校师生开放。活动旨在发掘校园配音人才，丰富同学们的课余生活，同时传播声音艺术的魅力。大赛涵盖动画、电影、电视剧等多种配音形式，分为初赛、决赛两个阶段。</p>
          </div>
          
          <div class="activity-review">
            <h4 class="review-title">往届回顾</h4>
            <div class="carousel-wrapper">
              <div class="carousel">
                <div class="slides" :style="{ transform: `translateX(-${currentSlide.dubbing * 100}%)` }">
                  <div class="slide" v-for="(item, index) in dubbingContestBanners" :key="index">
                    <img :src="item.img" class="carousel-image" :alt="item.title">
                    <div class="carousel-caption">
                      <h3>{{ item.title }}</h3>
                      <p>{{ item.desc }}</p>
                    </div>
                  </div>
                </div>
                <button class="carousel-control prev" @click="prevSlide('dubbing')">❮</button>
                <button class="carousel-control next" @click="nextSlide('dubbing')">❯</button>
                <div class="carousel-indicators">
                  <span v-for="(item, index) in dubbingContestBanners" 
                        :key="index" 
                        :class="{ active: currentSlide.dubbing === index }"
                        @click="goToSlide('dubbing', index)"></span>
                </div>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 主持人大赛 -->
        <div class="activity-card">
          <div class="activity-header">
            <div class="activity-badge">品牌活动</div>
            <h3 class="activity-title">主持人大赛</h3>
          </div>
          
          <div class="activity-intro">
            <p>主持人大赛是广播台的品牌活动之一，旨在选拔优秀的校园主持人才，为各类校园活动储备主持力量。大赛通过台风展示、即兴发挥、模拟主持等环节，全面考察选手的语言表达能力、临场反应能力和舞台表现力，是校园中极具影响力的赛事活动。</p>
          </div>
          
          <div class="activity-review">
            <h4 class="review-title">往届回顾</h4>
            <div class="carousel-wrapper">
              <div class="carousel">
                <div class="slides" :style="{ transform: `translateX(-${currentSlide.host * 100}%)` }">
                  <div class="slide" v-for="(item, index) in hostContestBanners" :key="index">
                    <img :src="item.img" class="carousel-image" :alt="item.title">
                    <div class="carousel-caption">
                      <h3>{{ item.title }}</h3>
                      <p>{{ item.desc }}</p>
                    </div>
                  </div>
                </div>
                <button class="carousel-control prev" @click="prevSlide('host')">❮</button>
                <button class="carousel-control next" @click="nextSlide('host')">❯</button>
                <div class="carousel-indicators">
                  <span v-for="(item, index) in hostContestBanners" 
                        :key="index" 
                        :class="{ active: currentSlide.host === index }"
                        @click="goToSlide('host', index)"></span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <Footer />
  </div>
</template>

<script setup>
import Header from '@/components/Header.vue'
import Footer from '@/components/Footer.vue'
import { ref } from 'vue'

// 当前幻灯片索引
const currentSlide = ref({
  quanta: 0,
  dubbing: 0,
  host: 0
})

// 切换上一张
const prevSlide = (type) => {
  const maxIndex = type === 'quanta' ? quantaBanners.value.length - 1 : 
                   type === 'dubbing' ? dubbingContestBanners.value.length - 1 : 
                   hostContestBanners.value.length - 1
  currentSlide.value[type] = currentSlide.value[type] === 0 ? maxIndex : currentSlide.value[type] - 1
}

// 切换下一张
const nextSlide = (type) => {
  const maxIndex = type === 'quanta' ? quantaBanners.value.length - 1 : 
                   type === 'dubbing' ? dubbingContestBanners.value.length - 1 : 
                   hostContestBanners.value.length - 1
  currentSlide.value[type] = currentSlide.value[type] === maxIndex ? 0 : currentSlide.value[type] + 1
}

// 跳转到指定幻灯片
const goToSlide = (type, index) => {
  currentSlide.value[type] = index
}

// 全台大会轮播图数据
const quantaBanners = ref([
  {
    img: new URL('@/assets/quantai/22届开场.jpg', import.meta.url).href,
    title: '22届全台大会',
    desc: '年度工作总结与表彰大会'
  },
  {
    img: new URL('@/assets/quantai/22届合影.jpg', import.meta.url).href,
    title: '22届全台大会',
    desc: '新老成员交接'
  },
  {
    img: new URL('@/assets/quantai/22届团建.jpg', import.meta.url).href,
    title: '22届全台大会',
    desc: '22届户外培训'
  }
])

// 配音秀大赛轮播图数据
const dubbingContestBanners = ref([
  {
    img: new URL('@/assets/dubbing/配音秀.jpg', import.meta.url).href,
    title: '首届配音秀大赛',
    desc: '吸引全校200余名选手参与'
  },
  {
    img: new URL('@/assets/dubbing/选手.jpg', import.meta.url).href,
    title: '选手合影',
    desc: '东软配音前10强'
  },
  {
    img: new URL('@/assets/dubbing/选手嘉宾.jpg', import.meta.url).href,
    title: '选手嘉宾合影留念',
    desc: '各二级学院、各社团优秀成员代表一致好评'
  },
  {
    img: new URL('@/assets/dubbing/工作人员.jpg', import.meta.url).href,
    title: '工作人员合影',
    desc: '首届配音秀大赛赛事工作组集体工作'
  }
])

// 主持人大赛轮播图数据
const hostContestBanners = ref([
  {
    img: new URL('@/assets/host/主持人23.jpg', import.meta.url).href,
    title: '第23届主持人大赛',
    desc: '决赛现场观众达700人'
  },
  {
    img: new URL('@/assets/host/主持人22.jpg', import.meta.url).href,
    title: '第22届主持人大赛',
    desc: '声动舞台 梦启未来'
  },
  {
    img: new URL('@/assets/host/主持人21.jpg', import.meta.url).href,
    title: '第21届主持人大赛',
    desc: '选拔出10名校园金牌主持人'
  }
])
</script>

<style scoped>
.activity-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f8f9fa;
  color: #333;
}

.activity-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px;
}

/* 页面标题样式 */
.page-header {
  text-align: center;
  margin-bottom: 60px;
  padding-bottom: 20px;
  position: relative;
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, #3498db, #2ecc71);
  border-radius: 2px;
}

.page-title {
  font-size: 2.5rem;
  background: linear-gradient(135deg, #2c3e50, #3498db);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 15px;
  font-weight: 700;
}

.page-subtitle {
  color: #7f8c8d;
  font-size: 1.1rem;
  max-width: 700px;
  margin: 0 auto;
}

/* 活动卡片容器 */
.activities-wrapper {
  display: grid;
  gap: 40px;
}

/* 活动卡片样式 */
.activity-card {
  background-color: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  position: relative;
}

.activity-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

/* 活动头部 */
.activity-header {
  padding: 25px 30px;
  border-bottom: 1px solid #f1f1f1;
  display: flex;
  align-items: center;
  gap: 15px;
}

.activity-badge {
  background-color: #3498db;
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.activity-card:nth-child(2) .activity-badge {
  background-color: #e74c3c;
}

.activity-card:nth-child(3) .activity-badge {
  background-color: #2ecc71;
}

.activity-title {
  font-size: 1.8rem;
  color: #2c3e50;
  margin: 0;
  font-weight: 600;
}

/* 活动介绍 */
.activity-intro {
  padding: 25px 30px;
  line-height: 1.8;
  color: #555;
  font-size: 1.05rem;
  background-color: #fafafa;
}

/* 往届回顾区域 */
.activity-review {
  padding: 30px;
}

.review-title {
  color: #2c3e50;
  margin-bottom: 20px;
  font-size: 1.3rem;
  position: relative;
  padding-left: 12px;
}

.review-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 18px;
  background-color: #3498db;
  border-radius: 2px;
}

.activity-card:nth-child(2) .review-title::before {
  background-color: #e74c3c;
}

.activity-card:nth-child(3) .review-title::before {
  background-color: #2ecc71;
}

/* 轮播图样式 */
.carousel-wrapper {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  position: relative;
}

.carousel {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
}

.slides {
  display: flex;
  transition: transform 0.5s ease;
  height: 100%;
}

.slide {
  min-width: 100%;
  position: relative;
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 3px 20px;
  text-align: left;
}

.carousel-caption h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.carousel-caption p {
  margin: 0;
  font-size: 1rem;
}

.carousel-control {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.3);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.carousel-control:hover {
  background: rgba(255, 255, 255, 0.5);
}

.prev {
  left: 15px;
}

.next {
  right: 15px;
}

.carousel-indicators {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  z-index: 10;
}

.carousel-indicators span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.3s ease;
}

.carousel-indicators span.active {
  background-color: white;
  transform: scale(1.2);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }
  
  .activity-header {
    padding: 20px;
  }
  
  .activity-title {
    font-size: 1.5rem;
  }
  
  .activity-intro,
  .activity-review {
    padding: 20px;
  }
  
  .carousel {
    height: 300px;
  }
  
  .carousel-caption h3 {
    font-size: 1.2rem;
  }
  
  .carousel-caption p {
    font-size: 0.9rem;
  }
  
  .carousel-control {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }
}
</style>